libname dd 'D:\local_c\bfeed3';

**for REStat p-aper, Breastfeeding and Children's EarlyCognitive Outcomes";

data x;
infile 'D:\local_c\bfeed3\afqt79.dat' lrecl=33 missover DSD DLM=' ';
input
  R0000100
  R0000500
  R0410300
  R0614700
  R0618011
  R0618017
  R0618100
  R0618300
  ;
label R0000100 = "ID# (1-12686) 79";
label R0000500 = "DATE OF BIRTH - YR 79";
label R0410300 = "DATE OF BIRTH - YR 81";
label R0614700 = "PROFILES ASVAB SAMPLNG WEIGHT 81";
label R0618011 = "PROFILES ASVAB SEC 2-STD SCRNR 81";
label R0618017 = "PROFILES ASVAB SEC 8-STD SCRNR 81";
label R0618100 = "PROFILES ASVAB VRBL-STD SCRNR 81";
label R0618300 = "PROFILES AFQT PRCTILE 89 (REV) 81";

data y;
set x;

sumstsc = r0618011 + r0618017 + 2*r0618100;
if sumstsc lt 0 then delete;
score = sumstsc;

yob = r0410300;
if yob lt 57 then do;
   yob = r0000500;
end;
if yob gt 64 then do;
   yob = r0000500;
end;

proc sort;  by yob;  run;

proc standard data = y out = z vardef = weight
              mean = 0 std = 1 print;  by yob;
			  var sumstsc;
			  weight r0614700;
			  run;

proc means;
run;
proc means;  by yob;  
run;
*note, if you weight it, you will get a mean score of 0, std of 1;

data dd.afqt79;
set z;
keep r0000100 afqt yob;
afqt = sumstsc;

proc means;
run;
proc print;
run;
